package com.app.core.mvc.repeat;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.redis.core.StringRedisTemplate;

import java.util.concurrent.TimeUnit;

/**
 * @author qiangt
 * @since 2023/6/15 10:37
 */
@Slf4j
@RequiredArgsConstructor
public class RedisRepeatCommitCache implements RepeatCommitCache {

    private final StringRedisTemplate stringRedisTemplate;

    @Override
    public String get(final String key) {
        return this.stringRedisTemplate.opsForValue().get(key);
    }

    @Override
    public void set(final String key, final String value, final long timeout, final TimeUnit unit) {
        this.stringRedisTemplate.opsForValue().set(key, value, timeout, unit);
    }

    @Override
    public void delete(String key) {
        this.stringRedisTemplate.delete(key);
    }

}
